#include <stdio.h>
#include <locale.h>
#include <string.h>
#include <wchar.h>
#include <iostream>
using namespace std;

void print_locale_names()
{
    cout << "#######################################################\n";
    cout << "##\t Current global locale: " << locale().name() << "\n";
    cout << "##\t Classic C locale: " << locale::classic().name() << "\n";
    cout << "##\t User's preferred locale: " << locale("").name() << "\n";
    cout << "#######################################################\n";
}
void using_cpp_output()
{
    //locale loc("zh_CN.utf8");
    locale loc("");
    locale pre_loc = std::wcout.imbue(loc);
    wchar_t p[] =  L"中国";
    std::wcout << p << std::endl;
    wcout.imbue(pre_loc);
    
}

void using_c_output()
{
//    print_locale_names();
    wchar_t p[] =  L"中国";
    setlocale(LC_ALL, "");
    wprintf(L"%d\n", wcslen(p));
    wprintf(L"%s\n", p);
}

int main()
{
    //using_c_output();
    using_cpp_output();
}
